package com.v3admin.common.exception;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * 业务处理异常
 *
 * @author Junpeng.Li
 * @date 2023-12-13 17:52
 */
@Getter
@Setter
public class BusinessException extends RuntimeException {

    /**
     * 错误码，默认值 = 500
     */
    private Integer code = 500;

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message, Object... params) {
        super(StrUtil.format(message, params));
    }

    public BusinessException(int code, String message, Object... params) {
        super(StrUtil.format(message, params));
        this.code = code;
    }

    public BusinessException(Throwable cause) {
        super(cause);
    }

    public BusinessException(int code, Throwable cause) {
        super(cause);
        this.code = code;
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
    }

    public BusinessException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
}
